/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FramePrincipal.java
 *
 * Created on 22/11/2009, 19:01:08
 */
package user_gui;

import elemento.ClienteTelefone;
import in_out.ComunicaBD;
import in_out.GeraRelatorio;
import in_out.IOUtils;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import op.Config;
import op.ContaTelefonica;
import op.DescontoTelefone;
import op.EntradaAbstrata;
import op.Ligacao;
import op.LigacaoDDD;
import op.LigacaoPlano;
import op.LigacaoResumida;
import op.LigacoesDestino;
import op.TarifaPlano;
import op.Telefone;
import op.Utils;
import op.ValorFinal;
import user_gui.contasresumidas.FrameResumo;

/**
 *
 * @author Jonatas
 */
public class FramePrincipal extends javax.swing.JFrame {

//    public static String bdName = "D:\\dist\\usuario_telefone.sqlite";
//    public static String bdName = "C:\\Users\\Jônatas\\Desktop\\usuario_telefone.sqlite";
    public static String bdName = "usuario_telefone.sqlite";
    public static String tableName = "usuario_telefone";
    public static ComunicaBD COMUNICABD = null;

    /** Creates new form FramePrincipal */
    public FramePrincipal() {
        
        COMUNICABD = new ComunicaBD(bdName);
        try {
            if (!new File(bdName).exists()) {
                COMUNICABD.createTables();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        initComponents();
//        menuItemTesteJasper.setVisible(false);



        botaoExibeLigacoes.setEnabled(false);


    }

    private void atualizaNome(String telefone, JLabel label) {

        ClienteTelefone cliente = null;
        try {
            cliente = COMUNICABD.select(tableName, telefone);
        } catch (SQLException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (cliente != null) {
            label.setText(cliente.getNome());
        } else {
            label.setText("");
        }

    }

    public void atualizaOrigem(String telefone) {
        atualizaNome(telefone, lblOrigem);
        if (temDestino) {
            temDestino = false;
            setNomeTelefone(jTable1, 1, this.lblDestino, false);
        }
    }
    protected boolean temDestino = false;

    public void atualizaDestino(String telefone) {
        atualizaNome(telefone, lblDestino);
    }

    private void writeConfig() {
        try {
            Config.writeConfigs();
        } catch (Exception ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private LigacaoResumida ligacaoResumidaFromTable(int row) {
        String telefoneOrigem = jTable1.getValueAt(row, 0).toString();
        telefoneOrigem = telefoneOrigem.replace(" ", "");
        telefoneOrigem = telefoneOrigem.replace("-", "");
        telefoneOrigem = telefoneOrigem.replace("(", "");
        telefoneOrigem = telefoneOrigem.replace(")", "");

        Telefone telOrigem = new Telefone(telefoneOrigem);

        String telefoneDestino = jTable1.getValueAt(row, 1).toString();
        telefoneDestino = telefoneDestino.replace(" ", "");
        telefoneDestino = telefoneDestino.replace("-", "");
        telefoneDestino = telefoneDestino.replace("(", "");
        telefoneDestino = telefoneDestino.replace(")", "");

        Telefone telDestino = new Telefone(telefoneDestino);

        int quantidade = Integer.parseInt(jTable1.getValueAt(row, 3).toString());

        String temp = jTable1.getValueAt(row, 4).toString().replace(",", ".");
        temp = temp.replace("R$", "");
        temp = temp.trim();

        double valor = Double.parseDouble(temp);

        LigacaoResumida ligacao = null;

        LigacaoResumida ligTemp = new LigacaoResumida(telOrigem, telDestino, valor, quantidade, 0, null, false);

        for (LigacaoResumida lig : ligacoes) {
            if (lig.equals(ligTemp)) {
                ligacao = lig;
                break;
            }
        }

        return ligacao;


    }

    private void populaTabelaRelatorio() {

        List<LigacaoDDD> ligacoesDDD = Utils.getLigacaoDDD(ligacoes);

        String[][] data = new String[ligacoesDDD.size() * 2][8];

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        int i = 0;

        int tempoTotal = 0;

        for (LigacaoDDD ligDDD : ligacoesDDD) {


            tempoTotal += ligDDD.getTempoCel() + ligDDD.getTempoFixo();

            data[i][0] = "Fixo";
            data[i][1] = ligDDD.getDdd();
            data[i][2] = "" + EntradaAbstrata.getDuracaoHoras((int) ligDDD.getTempoFixo());
            data[i][3] = "" + nf.format(ligDDD.getCustoFixo());
            data[i][4] = "" + ligDDD.getQtdeFixo();

            double tempo = ligDDD.getTempoFixo();
            tempo /= 60.0;
            double valorMinuto = tempo > 0.0 ? ligDDD.getCustoFixo() / tempo : 0.0;

            data[i][5] = "" + nf.format(valorMinuto);

            double valorLigacao = ligDDD.getQtdeFixo() > 0 ? ((double) ligDDD.getCustoFixo()) / ((double) ligDDD.getQtdeFixo()) : 0.0;

            data[i][6] = "" + nf.format(valorLigacao);

            double segundosPorLigacao = ligDDD.getQtdeFixo() > 0 ? ((double) ligDDD.getTempoFixo()) / ((double) ligDDD.getQtdeFixo()) : 0.0;

            data[i++][7] = "" + EntradaAbstrata.getDuracaoHoras((int) segundosPorLigacao);

            data[i][0] = "Celular";
            data[i][1] = ligDDD.getDdd();
            data[i][2] = "" + EntradaAbstrata.getDuracaoHoras((int) ligDDD.getTempoCel());
            data[i][3] = "" + nf.format(ligDDD.getCustoCel());
            data[i][4] = "" + ligDDD.getQtdeCel();

            tempo = ligDDD.getTempoCel();
            tempo /= 60.0;
            valorMinuto = tempo > 0.0 ? ligDDD.getCustoCel() / tempo : 0.0;

            data[i][5] = "" + nf.format(valorMinuto);

            valorLigacao = ligDDD.getQtdeCel() > 0 ? ((double) ligDDD.getCustoCel()) / ((double) ligDDD.getQtdeCel()) : 0.0;

            data[i][6] = "" + nf.format(valorLigacao);

            segundosPorLigacao = ligDDD.getQtdeCel() > 0 ? ((double) ligDDD.getTempoCel()) / ((double) ligDDD.getQtdeCel()) : 0.0;

            data[i++][7] = "" + EntradaAbstrata.getDuracaoHoras((int) segundosPorLigacao);

        }

        tabelaRelatorio.setModel(new DefaultTableModel(data, new String[]{
                    "Tipo", "DDD", "Tempo", "Custo", "Ligações", "Valor/Minuto", "Valor/Ligação", "Minutos/Ligação"
                }) {

            @Override
            public boolean isCellEditable(int row, int column) {
                return false;
            }
        });

        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tabelaRelatorio.getModel());
        sorter.setComparator(4, compareInteger);
        sorter.setComparator(3, compareCurrency);

        tabelaRelatorio.setRowSorter(sorter);

        String horas = EntradaAbstrata.getDuracaoHoras(tempoTotal);
        lblTempoTotal.setText(horas);

    }

    private class CompareInteger implements Comparator {

        public int compare(Object o1, Object o2) {
            String s1 = o1.toString();
            String s2 = o2.toString();

            return new Integer(s1).compareTo(new Integer(s2));
        }
    }

    private class CompareCurrency implements Comparator {

        public int compare(Object o1, Object o2) {

            String s1 = o1.toString().replaceAll(".[$]", "").replace(" ", "").replace(",", ".");
            String s2 = o2.toString().replaceAll(".[$]", "").replace(" ", "").replace(",", ".");

            Double d1 = new Double(s1);
            Double d2 = new Double(s2);

            return d1.compareTo(d2);

        }
    }

    private void changeLigacoes() {

        List<Ligacao> ligacoesTotais = conta.getLigacoes();

        for (Ligacao lig : ligacoesTotais) {

            try {
                if (lig.getPlanoLigacao().equals(tarifaAtual.getPlano())) {
                    if (lig.isACobrar()) {
                        lig.setCusto(getValorTotalComTarifas(lig.getDuracaoLigacaoACobrarSegundos(), tarifaAtual.getTarifa()));
                    } else {
                        lig.setCusto(getValorTotalComTarifas(lig.getDuracaoLigacaoSegundos(), tarifaAtual.getTarifa()));
                    }

                }
            } catch (Exception e) {
                System.out.println("TarifaAtual Plano: " + tarifaAtual.getPlano() + "\t TarifaAtualValor: " + tarifaAtual.getTarifa());
                System.out.println("Ligação atual Plano: " + lig.getPlanoLigacao() + "\t LigacaoAtual Duracao: " + lig.getDuracaoLigacaoSegundos());
                System.out.println("Ligacao atual Origem: " + lig.getNumeroDeOrigem() + "\tLigacao atual destino: " + lig.getDestino());
                System.out.println("\n-------------------------------------------------\n");
            }

        }

        conta.setLigacoes(ligacoesTotais);

        /*ligacoes = ContaTelefonica.getContasResumidas(ligacoesTotais);
        ligParaDestino = LigacoesDestino.findLigacoesDestino(conta.getLigacoes());*/

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblNumLig = new javax.swing.JLabel();
        lblValor = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        planosComboBox = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        lblTarifaAtual = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtNovaTarifa = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        lblOrigem = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        lblDestino = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        botaoExibeLigacoes = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        lblTempoTotal = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        tabelaRelatorio = new javax.swing.JTable();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();
        menuItemTesteJasper = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Cálculo de Contas");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel2.setText("Total de ligacoes:");

        jLabel3.setText("Valor total gasto:");

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Tarifas"));

        planosComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                planosComboBoxActionPerformed(evt);
            }
        });

        jLabel4.setText("Valor Atual:");

        jLabel6.setText("Novo Valor:");

        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(planosComboBox, 0, 488, Short.MAX_VALUE)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(10, 10, 10)
                        .addComponent(lblTarifaAtual, javax.swing.GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtNovaTarifa, javax.swing.GroupLayout.DEFAULT_SIZE, 369, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(planosComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(lblTarifaAtual, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtNovaTarifa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addContainerGap(73, Short.MAX_VALUE))
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel4, lblTarifaAtual});

        jLabel5.setText("Origem:");

        jButton2.setText("Editar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel11.setText("Destino:");

        jButton5.setText("Editar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        botaoExibeLigacoes.setText("Exibir Ligações");
        botaoExibeLigacoes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoExibeLigacoesActionPerformed(evt);
            }
        });

        jLabel1.setText("Tempo total:");

        lblTempoTotal.setText(" ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblNumLig, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblValor, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel11)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lblDestino, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(lblOrigem, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton5)
                                    .addComponent(jButton2)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblTempoTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(botaoExibeLigacoes))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(lblTempoTotal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lblNumLig, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2))
                        .addGap(5, 5, 5)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lblValor, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lblOrigem, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5)))
                    .addComponent(jButton2))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(lblDestino, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(botaoExibeLigacoes))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5)))
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número de Origem", "Número de Destino", "Tempo Total", "Quantidade de Ligações", "Valor Total", "Tipo de Ligação"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jTabbedPane1.addTab("Numero de Origem", jScrollPane1);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número de Destino", "Quantidade de Ligações", "Tempo Total", "Valor Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable2MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jTable2);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 942, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2)
        );

        jTabbedPane1.addTab("Numero de Destino", jPanel2);

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número de Origem", "Plano", "Quantidade de Ligações", "Valor Total", "Tempo Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable3MouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(jTable3);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 942, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3)
        );

        jTabbedPane1.addTab("Plano Utilizado", jPanel3);

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Número de Origem", "Quantidade de Ligações", "Valor Total", "Tempo Total"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable4MouseClicked(evt);
            }
        });
        jScrollPane4.setViewportView(jTable4);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 942, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4)
        );

        jTabbedPane1.addTab("Total", jPanel5);

        tabelaRelatorio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Tipo", "DDD", "Tempo", "Custo", "Ligações", "Valor/Minuto", "Valor/Ligação", "Minutos/Ligação"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane5.setViewportView(tabelaRelatorio);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 942, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5)
        );

        jTabbedPane1.addTab("Relatório", jPanel6);

        jMenu1.setMnemonic('A');
        jMenu1.setText("Arquivo");
        jMenu1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu1ActionPerformed(evt);
            }
        });

        jMenuItem1.setText("Abrir");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Salvar");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        jMenuItem12.setText("Salvar Relatório");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem12);

        jMenuItem13.setText("Salvar Telefones");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem13ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem13);

        menuItemTesteJasper.setText("Outros Relatórios");
        menuItemTesteJasper.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemTesteJasperActionPerformed(evt);
            }
        });
        jMenu1.add(menuItemTesteJasper);

        jMenuItem3.setText("Sair");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem3);

        jMenuBar1.add(jMenu1);

        jMenu3.setMnemonic('B');
        jMenu3.setText("Banco de Dados");
        jMenu3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu3ActionPerformed(evt);
            }
        });

        jMenuItem4.setText("Inserir");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem4);

        jMenuItem5.setText("Busca por número");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem5ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem5);

        jMenuItem10.setText("Busca por nome");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem10);

        jMenuItem9.setText("Listar Banco");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem9);

        jMenuItem11.setText("Inserir arquivo csv");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem11);

        jMenuItem14.setText("Inserir empresa");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem14ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem14);

        jMenuBar1.add(jMenu3);

        jMenu4.setMnemonic('R');
        jMenu4.setText("Resumo De Contas");

        jMenuItem6.setText("Resumo Oi");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem6ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem6);

        jMenuBar1.add(jMenu4);

        jMenu5.setMnemonic('F');
        jMenu5.setText("Filtros");

        jMenuItem7.setText("Aplicar Filtros");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem7);

        jMenuItem8.setText("Limpar Filtros");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu5.add(jMenuItem8);

        jMenuBar1.add(jMenu5);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 947, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1)
                .addGap(14, 14, 14))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-983)/2, (screenSize.height-730)/2, 983, 730);
    }// </editor-fold>//GEN-END:initComponents

    private void populaTabela2() {
        ligParaDestino = LigacoesDestino.findLigacoesDestino(conta.getLigacoes());
        Collections.sort(ligParaDestino);

        String[][] dataTable2 = new String[ligParaDestino.size()][4];
        String[] columnNames = {"Número de Destino", "Quantidade de Ligações", "Tempo Total", "Valor Total"};

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        for (int i = 0; i < dataTable2.length; i++) {
            LigacoesDestino lig = ligParaDestino.get(i);
            dataTable2[i][0] = "" + lig.getDestino().toString();
            dataTable2[i][1] = "" + lig.getQtdeLigacoes();
            dataTable2[i][2] = "" + lig.getTempoTotalHoras();
            dataTable2[i][3] = "" + nf.format(lig.getValorTotal());
        }


        DefaultTableModel model = new DefaultTableModel(dataTable2, columnNames) {

            boolean[] canEdit = new boolean[]{
                false, false, false, false};

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        };

        jTable2.setModel(model);

        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jTable2.getModel());
        sorter.setComparator(1, compareInteger);
        sorter.setComparator(3, compareCurrency);

        jTable2.setRowSorter(sorter);

    }

    private void atualizaTabela4() {

        Map<Telefone, DescontoTelefone> descontos = DescontoTelefone.getDescontos(conta.getLigacoes());
        valoresFinais = ValorFinal.getListValoresFinais(ligPlano, tarifas, descontos);
        Collections.sort(valoresFinais);

        String[] titulo = {"Número de Origem", "Quantidade de Ligações", "Valor Total", "Tempo Total"};
        String[][] dataValoresFinais = new String[valoresFinais.size()][4];

        NumberFormat nf = NumberFormat.getCurrencyInstance();
        for (int i = 0; i < valoresFinais.size(); i++) {
            ValorFinal vf = valoresFinais.get(i);

            dataValoresFinais[i][0] = "" + vf.getOrigem();
            dataValoresFinais[i][1] = "" + vf.getNum();

            dataValoresFinais[i][2] = "" + nf.format(vf.getValorTotal());

            dataValoresFinais[i][3] = "" + vf.getTempoTotalHoras();

        }

        DefaultTableModel model = new DefaultTableModel(dataValoresFinais, titulo) {

            boolean[] canEdit = new boolean[]{
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        };

        jTable4.setModel(model);

        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jTable4.getModel());
        sorter.setComparator(1, compareInteger);
        sorter.setComparator(2, compareCurrency);

        jTable4.setRowSorter(sorter);

    }

    private void populaTabela3() {

        ligPlano = LigacaoPlano.getListLigacaoPlano(conta.getLigacoes());
        Collections.sort(ligPlano);

        String[][] dataTable3 = new String[ligPlano.size()][5];
        String[] columnNames = {"Número de Origem", "Plano", "Quantidade de Ligações", "Valor Total", "Tempo Total"};

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        for (int i = 0; i < dataTable3.length; i++) {
            LigacaoPlano lig = ligPlano.get(i);



            TarifaPlano tarifaPlano = new TarifaPlano(lig.getPlano());
            if (!tarifas.contains(tarifaPlano)) {
                tarifas.add(tarifaPlano);
            }


            dataTable3[i][0] = "" + lig.getOrigem().toString();
            dataTable3[i][1] = "" + lig.getPlano();
            dataTable3[i][2] = "" + lig.getQtdeLigacoes();

            if (lig.getValorTotal() <= 0) {

                tarifaPlano = null;

                for (TarifaPlano tp : tarifas) {
                    if (tp.getPlano().equals(lig.getPlano())) {
                        tarifaPlano = tp;
                        break;
                    }
                }

                dataTable3[i][3] = "" + nf.format(getValorTotalComTarifas(lig.getTempoTotal(), tarifaPlano.getTarifa()));


            } else {
                dataTable3[i][3] = "" + nf.format(lig.getValorTotal());
            }

            dataTable3[i][4] = "" + lig.getTempoHoras();
        }


        DefaultTableModel model = new DefaultTableModel(dataTable3, columnNames) {

            boolean[] canEdit = new boolean[]{
                false, false, false, false, false};

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        };

        jTable3.setModel(model);


        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jTable3.getModel());
        sorter.setComparator(2, compareInteger);
        sorter.setComparator(3, compareCurrency);

        jTable3.setRowSorter(sorter);


        atualizaTabela4();
    }

    public static double getValorTotalComTarifas(int tempoSegundos, double tarifa) {

        double total = 0.0;

        int min = tempoSegundos / 60;
        tempoSegundos %= 60;
        total += (min * tarifa);

        if (tempoSegundos > 0) {
            total += tarifa / 2;
            tempoSegundos -= 30;

            double tarifaProp = tarifa / 10.0;

            while (tempoSegundos > 0) {
                total += tarifaProp;
                tempoSegundos -= 6;
            }
        }

        return total;

    }

    private void populaTarifaComboBox() {

        Collections.sort(tarifas);

        DefaultComboBoxModel model = new DefaultComboBoxModel(tarifas.toArray());

        planosComboBox.setModel(model);
        planosComboBox.setEditable(false);

        TarifaPlano tarifaPlano = (TarifaPlano) planosComboBox.getSelectedItem();

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        lblTarifaAtual.setText("" + nf.format(tarifaPlano.getTarifa()));

        txtNovaTarifa.setText("");

    }

    public static class MyFilter extends FileFilter {

        private String[] extraTypes;

        public MyFilter(String... extras) {
            if (extras.length > 0) {
                extraTypes = extras;
            }
        }

        @Override
        public boolean accept(File f) {

            if (f.isDirectory()) {
                return true;
            }

            String temp = f.getName();

            temp = temp.substring(temp.length() - 4);

            boolean b = temp.equalsIgnoreCase(".txt");

            if (extraTypes != null && extraTypes.length > 0) {
                for (String s : extraTypes) {

                    temp = temp.substring(temp.length() - s.length());

                    b = b || temp.equalsIgnoreCase(s);

                }
            }


            return b;
        }

        @Override
        public String getDescription() {

            String tipos = "*.txt";

            if (extraTypes != null && extraTypes.length > 0) {
                for (String s : extraTypes) {

                    tipos += ", *" + s;

                }
            }

            return tipos;
        }
    }

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed

        OpenFilesFrame openFiles = new OpenFilesFrame(this);
        openFiles.setVisible(true);

    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void populaTabelas() {

        if (conta == null || conta.getLigacoes() == null || conta.getLigacoes().isEmpty()) {
            JOptionPane.showMessageDialog(this, "Não há nenhuma ligação nessa faixa de horário.", "Aviso!", JOptionPane.INFORMATION_MESSAGE);
            conta = contaOriginal;
        }

        populaTabela1();

        populaTabela2();

        populaTabela3();

        populaTarifaComboBox();

        populaTabelaRelatorio();
    }

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed

        writeConfig();
        System.exit(0);

    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed

        String filePathChooser = null;
        try {
            Config config = Config.getInstance();

            filePathChooser = config.getPathChooserPrincipal();

        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }


        JFileChooser chooser = new JFileChooser(filePathChooser);
        chooser.setFileFilter(new FileFilter() {

            @Override
            public boolean accept(File f) {
                if (f.isDirectory()) {
                    return true;
                }

                return f.getName().endsWith(".xls");
            }

            @Override
            public String getDescription() {
                return "*.xls";
            }
        });

        chooser.showSaveDialog(this);
        File file = chooser.getSelectedFile();

        filePathChooser = file.getParent();

        if (file.exists()) {

            String[] options = {"Sim", "Não"};

            int ctz = JOptionPane.showOptionDialog(this, "Deseja sobrescrever o arquivo existente?", "Aviso",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

            if (ctz != 0) {
                return;
            }

        }

        String filePath = file.getAbsolutePath();
        if (!filePath.endsWith(".xls")) {
            filePath += ".xls";
        }

        String[] titulo = new String[4];//{"Número de Origem", "Quantidade de Ligações", "Valor Total", "Tempo Total"};

        for (int i = 0; i < titulo.length; i++) {
            titulo[i] = jTable4.getColumnName(i);
        }

        List<String[]> totalList = new ArrayList<String[]>();

        for (int i = 0; i < jTable4.getRowCount(); i++) {
            String[] linhaTotal = new String[4];
            linhaTotal[0] = jTable4.getValueAt(i, 0).toString();
            linhaTotal[1] = jTable4.getValueAt(i, 1).toString();
            linhaTotal[2] = jTable4.getValueAt(i, 2).toString();
            linhaTotal[3] = jTable4.getValueAt(i, 3).toString();

            totalList.add(linhaTotal);
        }

        boolean b = false;
        try {
            b = GeraRelatorio.createXLSReport(filePath, ligacoes, ligParaDestino,
                    ligPlano, tarifas, titulo, totalList, conta.getLigacoes());
        } catch (SQLException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (!b) {
            JOptionPane.showMessageDialog(this, "Houve um problema na escrita do arquivo, por favor verifique se este"
                    + "arquivo não está sendo utilizado por outra aplicação.", "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "O arquivo foi salvo com sucesso", "", JOptionPane.INFORMATION_MESSAGE);
        }
        try {

            if (filePathChooser != null) {
                Config.getInstance().setPathChooserPrincipal(filePathChooser);
            }
        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        TarifaPlano tp = (TarifaPlano) planosComboBox.getSelectedItem();

        if (tp == null) {
            JOptionPane.showMessageDialog(this, "Por favor, selecione um item.", "Erro", JOptionPane.ERROR_MESSAGE);
            return;
        }

        String num = txtNovaTarifa.getText().replace(',', '.');
        double novaTarifa = 0.0;

        try {
            novaTarifa = Double.parseDouble(num);
        } catch (NumberFormatException numberFormatException) {
            JOptionPane.showMessageDialog(this, "Por favor, utilize apenas números.", "Erro", JOptionPane.ERROR_MESSAGE);
            return;
        }

        if (novaTarifa < 0) {
            JOptionPane.showMessageDialog(this, "Por favor, utilize apenas números positivos.", "Erro", JOptionPane.ERROR_MESSAGE);
            return;
        }

        for (TarifaPlano tar : tarifas) {
            if (tp.equals(tar)) {
                tar.setTarifa(novaTarifa);
                tp.setTarifa(novaTarifa);
                break;
            }
        }

        tarifaAtual = tp;

        txtNovaTarifa.setText("");

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        lblTarifaAtual.setText("" + nf.format(novaTarifa));

        changeLigacoes();

        populaTabela1();

        populaTabela2();

        populaTabela3();

    }//GEN-LAST:event_jButton1ActionPerformed

    private void planosComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_planosComboBoxActionPerformed

        TarifaPlano tarifaPlano = (TarifaPlano) planosComboBox.getSelectedItem();

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        lblTarifaAtual.setText("" + nf.format(tarifaPlano.getTarifa()));

    }//GEN-LAST:event_planosComboBoxActionPerformed

    private void setNomeTelefone(JTable table, int position, JLabel label, boolean origem) {

        int row = table.getSelectedRow();
        String telefoneCompleto = table.getValueAt(row, position).toString();
        String telefone = table.getValueAt(row, position).toString();
        telefone = telefone.replace(" ", "");
        telefone = telefone.replace("-", "");
        telefone = telefone.replace("(", "");
        telefone = telefone.replace(")", "");
        ClienteTelefone cliente = null;
        try {
            cliente = COMUNICABD.select(tableName, telefone);
        } catch (SQLException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (cliente == null) {

            int resposta = JOptionPane.showConfirmDialog(this, "O telefone " + telefoneCompleto + " ainda não foi cadastrado, deseja cadastrá-lo?",
                    "ATENÇÃO", JOptionPane.YES_NO_OPTION);

            if (resposta == 0) {

                Cliente c = new Cliente(telefone, telefoneCompleto, this, origem, temDestino);
                c.setVisible(true);
            } else {
                label.setText("");
            }

            return;
        }

        if (temDestino) {
            vaiDestinoBatata();
        }


        if (origem) {
            this.origem = cliente;
            this.telefoneOrigemCompleto = telefoneCompleto;
        } else {
            this.destino = cliente;
            this.telefoneDestinoCompleto = telefoneCompleto;
        }
        label.setText(cliente.getNome());

    }

    public void vaiDestinoBatata() {
        temDestino = false;
        setNomeTelefone(jTable1, 1, this.lblDestino, false);
    }

    private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked

        temDestino = true;
        setNomeTelefone(jTable1, 0, this.lblOrigem, true);

    }//GEN-LAST:event_jTable1MouseClicked

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

        String nome = origem.getNome();

        if (nome.isEmpty()) {
            return;
        }

        String telefoneCompleto = telefoneOrigemCompleto;

        editaCliente(telefoneCompleto, nome, true);

    }//GEN-LAST:event_jButton2ActionPerformed

    private void editaCliente(String telefoneCompleto, String nome, boolean origem) {
        String telefone = telefoneCompleto.toString();
        telefone = telefone.replace(" ", "");
        telefone = telefone.replace("-", "");
        telefone = telefone.replace("(", "");
        telefone = telefone.replace(")", "");

        new EditaCliente(telefone, telefoneCompleto, this, nome, origem).setVisible(true);
    }

    private void jTable3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable3MouseClicked
        setNomeTelefone(jTable3, 0, lblOrigem, true);
        lblDestino.setText("");
    }//GEN-LAST:event_jTable3MouseClicked

    private void jTable4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable4MouseClicked
        setNomeTelefone(jTable4, 0, lblOrigem, true);
        lblDestino.setText("");
    }//GEN-LAST:event_jTable4MouseClicked

    public void setConta(ContaTelefonica conta) {

        if (conta == null) {
            this.conta = contaOriginal;
        } else {
            this.conta = conta;
        }

        ligacoes = this.conta.getContaResumida();

        populaTabelas();
    }

    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu1ActionPerformed

    public void semFiltros() {
        conta = contaOriginal;

        ligacoes = conta.getContaResumida();

        populaTabelas();
    }

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        String nome = destino.getNome();

        if (nome.isEmpty()) {
            return;
        }

        String telefoneCompleto = telefoneDestinoCompleto;

        editaCliente(telefoneCompleto, nome, false);
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
        setNomeTelefone(jTable2, 0, lblDestino, false);
        lblOrigem.setText("");
    }//GEN-LAST:event_jTable2MouseClicked

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed

        CadastraCliente cadastra = new CadastraCliente(this);
        cadastra.setVisible(true);

    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        new EditaRemoveCliente(this).setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed

        new FrameResumo().setVisible(true);

    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing

        writeConfig();

    }//GEN-LAST:event_formWindowClosing

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        conta = contaOriginal;

        ligacoes = conta.getContaResumida();

        populaTabelas();
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed

        new FiltrosFrame(this, contaOriginal).setVisible(true);

    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed

        new BancoInteiroFrame().setVisible(true);

    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        new BuscaPorNomeFrame().setVisible(true);
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked

        int tab = jTabbedPane1.getSelectedIndex();
        if (tab == 0 || tab == 1) {
            botaoExibeLigacoes.setEnabled(true);
        } else {
            botaoExibeLigacoes.setEnabled(false);
        }

    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void botaoExibeLigacoesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoExibeLigacoesActionPerformed

        int tab = jTabbedPane1.getSelectedIndex();

        if (tab == 0) {

            int row = jTable1.getSelectedRow();

            if (row == -1) {
                return;
            }

            LigacaoResumida lig = ligacaoResumidaFromTable(row);

            if (lig == null) {
                return;
            }

            List<Ligacao> telefonemas = Utils.getLigacoes(lig, conta);

            new ExibeLigacoes(telefonemas).setVisible(true);

        } else if (tab == 1) {

            int row = jTable2.getSelectedRow();
            if (row == -1) {
                return;
            }

            String telefoneDestino = jTable2.getValueAt(row, 0).toString();
            telefoneDestino = telefoneDestino.replace(" ", "");
            telefoneDestino = telefoneDestino.replace("-", "");
            telefoneDestino = telefoneDestino.replace("(", "");
            telefoneDestino = telefoneDestino.replace(")", "");

            Telefone telDestino = new Telefone(telefoneDestino);

            List<Ligacao> telefonemas = Utils.getLigacoesFromDestino(telDestino, conta);

            new ExibeLigacoes(telefonemas).setVisible(true);

        }

    }//GEN-LAST:event_botaoExibeLigacoesActionPerformed

    private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu3ActionPerformed
    }//GEN-LAST:event_jMenu3ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        String filePath = null;
        try {
            Config config = Config.getInstance();

            filePath = config.getPathChooserPrincipal();

        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

        JFileChooser chooser = new JFileChooser(filePath);
        chooser.setFileFilter(new MyFilter(".csv"));
        chooser.showOpenDialog(this);

        File csv = chooser.getSelectedFile();

        boolean b = Utils.insertMultipleTelefones(csv);

        if (!b) {
            JOptionPane.showMessageDialog(this, "Houve um problema na inserção dos registros.",
                    "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "O arquivo foi salvo com sucesso", "",
                    JOptionPane.INFORMATION_MESSAGE);
        }

    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        String filePathChooser = null;
        try {
            Config config = Config.getInstance();

            filePathChooser = config.getPathChooserPrincipal();

        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }


        JFileChooser chooser = new JFileChooser(filePathChooser);
        chooser.setFileFilter(new FileFilter() {

            @Override
            public boolean accept(File f) {
                if (f.isDirectory()) {
                    return true;
                }

                return f.getName().endsWith(".xls");
            }

            @Override
            public String getDescription() {
                return "*.xls";
            }
        });

        chooser.showSaveDialog(this);
        File file = chooser.getSelectedFile();

        filePathChooser = file.getParent();

        if (file.exists()) {

            String[] options = {"Sim", "Não"};

            int ctz = JOptionPane.showOptionDialog(this, "Deseja sobrescrever o arquivo existente?", "Aviso",
                    JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

            if (ctz != 0) {
                return;
            }

        }

        String filePath = file.getAbsolutePath();
        if (!filePath.endsWith(".xls")) {
            filePath += ".xls";
        }

        String[] titulo = new String[4];//{"Número de Origem", "Quantidade de Ligações", "Valor Total", "Tempo Total"};

        for (int i = 0; i < titulo.length; i++) {
            titulo[i] = jTable4.getColumnName(i);
        }

        List<String[]> totalList = new ArrayList<String[]>();

        for (int i = 0; i < jTable4.getRowCount(); i++) {
            String[] linhaTotal = new String[4];
            linhaTotal[0] = jTable4.getValueAt(i, 0).toString();
            linhaTotal[1] = jTable4.getValueAt(i, 1).toString();
            linhaTotal[2] = jTable4.getValueAt(i, 2).toString();
            linhaTotal[3] = jTable4.getValueAt(i, 3).toString();

            totalList.add(linhaTotal);
        }

        boolean b = false;

        try {
            b = GeraRelatorio.createSimpleXLSReport(filePath, ligacoes,
                    titulo, totalList);
        } catch (SQLException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (!b) {
            JOptionPane.showMessageDialog(this, "Houve um problema na escrita do arquivo, por favor verifique se este"
                    + "arquivo não está sendo utilizado por outra aplicação.", "Erro", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(this, "O arquivo foi salvo com sucesso", "", JOptionPane.INFORMATION_MESSAGE);
        }
        try {

            if (filePathChooser != null) {
                Config.getInstance().setPathChooserPrincipal(filePathChooser);
            }
        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void jMenuItem13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem13ActionPerformed
        String filePathChooser = null;
        try {
            Config config = Config.getInstance();

            filePathChooser = config.getPathChooserPrincipal();

        } catch (IOException ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }


        JFileChooser chooser = new JFileChooser(filePathChooser);
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

        chooser.showSaveDialog(this);
        File folder = chooser.getSelectedFile();
        try {
            IOUtils.saveMultipleReports(conta, tarifas, folder);
        } catch (Exception ex) {
            Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
            JOptionPane.showMessageDialog(this, "Houve um problema na escrita do arquivo, por favor verifique se este"
                    + "arquivo não está sendo utilizado por outra aplicação.", "Erro", JOptionPane.ERROR_MESSAGE);
            return;
        }
        JOptionPane.showMessageDialog(this, "Os arquivos foram salvos com sucesso", "", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jMenuItem13ActionPerformed

    private void menuItemTesteJasperActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemTesteJasperActionPerformed

        List<String[]> totalList = new ArrayList<String[]>();

        for (int i = 0; i < jTable4.getRowCount(); i++) {
            String[] linhaTotal = new String[4];
            linhaTotal[0] = jTable4.getValueAt(i, 0).toString();
            linhaTotal[1] = jTable4.getValueAt(i, 1).toString();
            linhaTotal[2] = jTable4.getValueAt(i, 2).toString();
            linhaTotal[3] = jTable4.getValueAt(i, 3).toString();

            totalList.add(linhaTotal);
        }

        FrameSaveReports reports = new FrameSaveReports(this, ligacoes, totalList);
        reports.setVisible(true);
//
//        try {
//            GeraNumeroDeOrigemReport.testJasper(ligacoes);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//        }
    }//GEN-LAST:event_menuItemTesteJasperActionPerformed

    private void jMenuItem14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem14ActionPerformed
        CadastraEmpresa cadastra = new CadastraEmpresa(this);
        cadastra.setVisible(true);
    }//GEN-LAST:event_jMenuItem14ActionPerformed

    private void populaTabela1() {

        ligacoes = ContaTelefonica.getContasResumidas(conta.getLigacoes());

        Collections.sort(ligacoes);

        String[][] dataTable1 = new String[ligacoes.size()][6];
        String[] columnNames = {"Número de Origem", "Número de Destino", "Tempo Total",
            "Quantidade de Ligações", "Valor Total", "Tipo de Ligação"};

        NumberFormat nf = NumberFormat.getCurrencyInstance();

        for (int i = 0; i
                < dataTable1.length; i++) {
            LigacaoResumida lig = ligacoes.get(i);
            dataTable1[i][0] = "" + lig.getOrigem().toString();
            dataTable1[i][1] = "" + lig.getDestino().toString();
            dataTable1[i][2] = "" + lig.getTempoEmHoras();
            dataTable1[i][3] = "" + lig.getNumLigacoes();
            dataTable1[i][4] = "" + nf.format(lig.getValorTotal());
            dataTable1[i][5] = "" + lig.getTipoDeLigacao();
        }

        DefaultTableModel model = new DefaultTableModel(dataTable1, columnNames) {

            boolean[] canEdit = new boolean[]{
                false, false, false, false, false, false
            };

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit[columnIndex];
            }
        };

        jTable1.setModel(model);

        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(jTable1.getModel());
        sorter.setComparator(3, compareInteger);
        sorter.setComparator(4, compareCurrency);

        jTable1.setRowSorter(sorter);

        int totalLigacoes = 0;
        double valorTotal = 0.0;

        for (LigacaoResumida lig : ligacoes) {
            totalLigacoes += lig.getNumLigacoes();
            valorTotal +=
                    lig.getValorTotal();
        }

        lblNumLig.setText("" + totalLigacoes);
        lblValor.setText(nf.format(valorTotal));

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            try {
                UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
            } catch (Exception ex) {
                Logger.getLogger(FramePrincipal.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FramePrincipal().setVisible(true);
            }
        });
    }

    public void setContaOriginal(ContaTelefonica contaOriginal) {
        this.contaOriginal = contaOriginal;
        tarifas = new ArrayList<TarifaPlano>();
        setConta(null);

        botaoExibeLigacoes.setEnabled(true);
    }

    public ContaTelefonica getConta() {
        return conta;
    }

    public ContaTelefonica getContaOriginal() {
        return contaOriginal;
    }
    protected ClienteTelefone origem = null;
    protected String telefoneOrigemCompleto = null;
    protected ClienteTelefone destino = null;
    protected String telefoneDestinoCompleto = null;
    private ContaTelefonica contaOriginal = null;
    private CompareInteger compareInteger = new CompareInteger();
    private CompareCurrency compareCurrency = new CompareCurrency();
    private ContaTelefonica conta = null;
    private List<LigacaoResumida> ligacoes = null;
    private List<LigacoesDestino> ligParaDestino = null;
    private List<LigacaoPlano> ligPlano = null;
    private List<TarifaPlano> tarifas = null;
    private List<ValorFinal> valoresFinais = null;
    private TarifaPlano tarifaAtual = null;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoExibeLigacoes;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTable jTable4;
    private javax.swing.JLabel lblDestino;
    private javax.swing.JLabel lblNumLig;
    private javax.swing.JLabel lblOrigem;
    private javax.swing.JLabel lblTarifaAtual;
    private javax.swing.JLabel lblTempoTotal;
    private javax.swing.JLabel lblValor;
    private javax.swing.JMenuItem menuItemTesteJasper;
    private javax.swing.JComboBox planosComboBox;
    private javax.swing.JTable tabelaRelatorio;
    private javax.swing.JTextField txtNovaTarifa;
    // End of variables declaration//GEN-END:variables
}
